package com.woniuxy.three.pms.util;


import java.util.Timer;
import java.util.TimerTask;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

import com.woniuxy.three.pms.bean.OrderBean;
import com.woniuxy.three.pms.order.service.IOrderService;
import com.woniuxy.three.pms.order.service.impl.OrderService;


public class TimerTaskUtil extends TimerTask {
		
	
	private IOrderService service;
	private Timer timer;
	private OrderBean order;
	
	
	public TimerTaskUtil(Timer timer,OrderBean order,IOrderService service){
		this.timer = timer;
		this.order=order;
		this.service=service;
	}
	@Override
	public void run() {
		//未支付  已支付 支付超时
		Integer orderid = order.getId();
		
		OrderBean orderdate=service.findbyid(order.getId());
		if(orderdate.getPayType().contains("未支付")){
			orderdate.setPayType("已超时");
			service.updateByPrimaryKeySelective(orderdate);
			//取消订单，恢复库存
			service.cancelOrderByid(orderdate.getId());
			
			timer.cancel();
		}else {
			
			timer.cancel();
		}
		
	}

}
